<?php if (isset($pager)): ?>
  <table cellspacing="0" class="root_table">
    <tbody>
      <tr>
      	<th>
           	<?php echo link_to_function('<span>Tiêu đề</span>', 'sort(\'name\', 1)') ?>
        </th>
        <th>
           	<?php echo link_to_function('<span>Tên file</span>', 'sort(\'file\', 1)') ?>
        </th>
        <th>
           	<?php echo link_to_function('<span>Kiểu file</span>', 'sort(\'file_type\', 1)') ?>
        </th>
        <th>
           	<?php echo link_to_function('<span>Kích thuớc</span>', 'sort(\'file_size\', 1)') ?>
        </th>
        <th>
        	<?php echo link_to_function('<span>Lượt xem</span>', 'sort(\'views_count\', 1)') ?>
        </th>
        <th>
        	<span>Kích hoạt</span>
        </th>
		<th>
			<?php echo link_to_function('<span>Ngày khởi tạo</span>', 'sort(\'created_at\', 1)') ?>
		</th>
		<th>
		  <?php echo "Thao Tác" ?>
		</th>
      </tr>

  <?php foreach ($pager->getResults() as $document): ?>
    <tr>
        <td><?php echo $document->name ?></td>
        <td style='text-align:center;'><?php echo ($document->file)? $document->file:"<img src='/images/false.gif' />"  ?></td>
        <td style='text-align:center;'><?php echo ($document->file_size)?$document->file_type:"<img src='/images/false.gif' />"  ?></td>
        <td style='text-align:center;'><?php echo ($document->file_type)?$document->file_size." KB":"<img src='/images/false.gif' />"  ?></td>
        <td style='text-align:center;'><?php echo $document->views_count ?></td>
        <td style='text-align:center;'><?php echo ($document->is_active)?"<img src='/images/true.gif' />":"<img src='/images/false.gif' />"  ?></td>
		<td style="text-align:center"><?php echo $document->created_at ?></td>
		<td style="text-align:center">
            <?php echo link_to('>>> Sửa', '@document_edit?document_id='.$document->document_id)."<br/>"?>
            <?php echo link_to('>>> Xóa', '@document_delete?document_id='.$document->document_id)?>
        </td>
    </tr>
  <?php endforeach ?>
    </tbody>
  </table>

  <?php if ($pager->haveToPaginate()): ?>
    <div class="pagination">
      <?php if (!$pager->isFirstPage()): ?>
        <?php echo link_to_function("First page", 'listReload('.$pager->getFirstPage().')', array('class' => 'page')) ?>
        <?php echo link_to_function("Prev", 'listReload('.$pager->getPreviousPage().')', array('class' => 'page')) ?>
      <?php endif ?>

      <?php foreach ($pager->getLinks() as $link): ?>
        <?php if ($link == $pager->getPage()): ?>
          <span class="page selected"><?php echo $link ?></span>
        <?php else: ?>
          <?php echo link_to_function($link, 'listReload('.$link.')', array('class' => 'page')) ?>
        <?php endif ?>
      <?php endforeach ?>

      <?php if (!$pager->isLastPage()): ?>
        <?php echo link_to_function("Next", 'listReload('.$pager->getNextPage().')', array('class' => 'page')) ?>
        <?php echo link_to_function("Last page", 'listReload('.$pager->getLastPage().')', array('class' => 'page')) ?>
      <?php endif ?>
    </div>
  <?php endif ?>
<?php endif ?>